package cn.kgc.tangcco.tcbd1011.bigredbook.tbuser.service.impl;

import java.util.List;

import cn.kgc.tangcco.tcbd1011.bigredbook.pageresult.PageResult;
import cn.kgc.tangcco.tcbd1011.bigredbook.tbuser.dao.UserDao;
import cn.kgc.tangcco.tcbd1011.bigredbook.tbuser.entity.Tbuser;
import cn.kgc.tangcco.tcbd1011.bigredbook.tbuser.service.UserService;
import cn.kgc.tangcco.tcbd1011.bigredbook.util.Utils;
import cn.kgc.tangcco.tcbd1011.weihuihui.comm.properties.factory.PropertiesFactory;

public class UserServiceImpl implements UserService {

	private UserDao udao;
	public UserServiceImpl() {
		udao=(UserDao) PropertiesFactory.getValue(Utils.TBUSERDAO);
	}

	@Override
	public Tbuser login(Tbuser user) {
		Tbuser login = this.udao.login(user);
		if(login!=null) {
			if(login.getPassword().equals(user.getPassword())) {
				return login;
			}
		}
		return null;
	}

	@Override
	public int addUser(Tbuser user) {
		return this.udao.addUser(user);
	}

	@Override
	public int updateUser(Tbuser user) {
		return this.udao.updateUser(user);
	}

	@Override
	public int deleteUser(int pk) {
		return this.udao.deleteUser(pk);
	}

	@Override
	public List<Tbuser> queryAllUser(Tbuser user, PageResult pages) {
		return this.udao.queryAllUser(user, pages);
	}

	@Override
	public Tbuser detailUser(int pk) {
		return this.udao.detailUser(pk);
	}

	@Override
	public int queryCountUser(Tbuser user) {
		return this.udao.queryCountUser(user);
	}

	@Override
	public Tbuser queryUserByUsername(String username) {
		Tbuser u  = new Tbuser();
		u.setAccout(username);
		Tbuser login = this.udao.login(u);
		return login;
	}

}
